import request from '@/utils/request';
import { _Comment } from '@/api/model/Comment';
import { R } from '../model/R';


/**
 * 发表评论(1级)
 */
export function sendComment(data: _Comment) {
    return request({
        url: `/business/comment`,
        method: 'post',
        data: data
    });
}
/**
 * 发表评论(2级)
 */
export function sendSecondComment(data: _Comment) {
    return request({
        url: `/business/comment/reply`,
        method: 'post',
        data: data
    });
}

/**
 * 获取评论列表
 */
export function listComment(query?: any): Promise<R<Comment>> {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    return request({
        url: `/business/comment/list`,
        method: 'get',
        params: query
    });
}
/**
 * 获取顶级评论获取子集评论列表
 */
export function selectChildByRootId(parentId:string|number): Promise<R<Comment>> {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    return request({
        url: `/business/comment/child/${parentId}`,
        method: 'get'
    });
}
/**
 * 获取一级评论列表
 */
export function listFirstComment(query?: any): Promise<R<Comment>> {
    query.status = true;
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    return request({
        url: `/business/comment/first`,
        method: 'get',
        params: query
    });
}

/**
 * 获取评论我的
 */
export function commentMy(query?: any): Promise<R<Comment>> {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    return request({
        url: `/business/comment/commentMy`,
        method: 'get',
        params: query
    });
}
/**
 * 获取已读和未读消息数量
 */
export function readAndNotReadCount(query?: any): Promise<R<Comment>> {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    return request({
        url: `/business/comment/readAndNotReadCount`,
        method: 'get',
        params: query
    });
}/**
 * 评论读取
 */
export function read(commentId:number|string): Promise<R<Comment>> {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    return request({
        url: `/business/comment/read/${commentId}`,
        method: 'get',
    });
}



